package com.aspose.cells;

import java.util.ArrayList;
import java.util.HashMap;

class zpy {
   private Workbook a;
   private WorksheetCollection b;
   private Cells c;
   private Worksheet d;
   private HashMap e = new HashMap();
   private int f = 5;
   private int g;
   private int h;
   private byte[] i;
   private byte[] j;
   private LoadDataOption k;
   private ArrayList l;
   private ArrayList m;
   private ArrayList n;
   private zsg o;

   zpy(Workbook var1, LoadDataOption var2) {
      this.a = var1;
      this.b = this.a.getWorksheets();
      this.b.clear();
      this.i = new byte[2];
      this.k = var2;
   }

   private void a(zpb var1) throws Exception {
      this.g = var1.b(this.i);
      if ((this.g & '\uffff') != 2057) {
         throw new Exception("Bad Workbook file format.");
      } else {
         this.h = var1.b(this.i);
         this.j = new byte[this.h];
         var1.a(this.j);
         if (this.j[1] == 6) {
            this.f = 5;
         } else {
            throw new Exception("Bad Workbook file format.");
         }
      }
   }

   private void b(zpb var1) throws Exception {
      this.c(var1);
      zxw var2 = new zxw();
      var2.b(this.j);
      com.aspose.cells.b.a.a.ze.a(this.b.A(), (Object)var2);
      int var3 = com.aspose.cells.b.a.zc.e(this.j, 0);
      if ((var3 & '\uffff') > (this.b.w() & '\uffff')) {
         this.b.e(var3);
      }

      while(true) {
         this.g = var1.b(this.i);
         if ((this.g & '\uffff') != 1054) {
            var1.a(-2);
            return;
         }

         this.c(var1);
         var2 = new zxw();
         var2.b(this.j);
         com.aspose.cells.b.a.a.ze.a(this.b.A(), (Object)var2);
         var3 = com.aspose.cells.b.a.zc.e(this.j, 0);
         if ((var3 & '\uffff') > (this.b.w() & '\uffff')) {
            this.b.e(var3);
         }
      }
   }

   private int c(zpb var1) throws Exception {
      this.h = var1.b(this.i);
      if ((this.h & '\uffff') != 0) {
         this.j = new byte[this.h];
         var1.a(this.j);
         this.l(var1);
      } else {
         this.j = null;
      }

      return this.h;
   }

   private void d(zpb var1) throws Exception {
      this.l = new ArrayList();
      this.c(var1);
      com.aspose.cells.b.a.a.ze.a(this.l, (Object)this.j);

      while(true) {
         this.g = var1.b(this.i);
         if ((this.g & '\uffff') != 224) {
            var1.a(-2);
            return;
         }

         this.c(var1);
         com.aspose.cells.b.a.a.ze.a(this.l, (Object)this.j);
      }
   }

   private void a(byte[] var1) {
      Style var2 = new Style(this.b);
      var2.a(var1);
      this.b.B().d(var2);
   }

   private void e(zpb var1) {
      try {
         String var2;
         if (this.j[7] == 0) {
            byte[] var4 = new byte[2 * this.j.length - 16];

            for(int var5 = 0; var5 < this.j.length - 8; ++var5) {
               var4[2 * var5] = this.j[8 + var5];
            }

            var2 = Encoding.getUnicode().a(var4);
         } else {
            var2 = Encoding.getUnicode().a(this.j, 8, this.j.length - 8);
         }

         if (var2.length() >= 32) {
            var2 = var2.substring(0, 31);
         }

         int var3 = this.b.c(var2);
         if (this.j[5] == 0) {
            this.b.get(var3).setType(1);
         } else if (this.j[5] == 2) {
            this.b.get(var3).setType(2);
         } else if (this.j[5] == 6) {
            this.b.get(var3).setType(0);
         } else {
            this.b.get(var3).setType(4);
         }

         this.b.get(var3).a(this.j[4]);
      } catch (Exception var6) {
         throw new CellsException(6, "Incalid sheet name info");
      }
   }

   private void f(zpb var1) throws Exception {
      ArrayList var2 = new ArrayList();
      this.c(var1);
      com.aspose.cells.b.a.a.ze.a(var2, (Object)this.j);

      while(true) {
         this.g = var1.b(this.i);
         if ((this.g & '\uffff') != 60) {
            var1.a(-2);
            zbby.a(var2, this.b);
            return;
         }

         this.c(var1);
         com.aspose.cells.b.a.a.ze.a(var2, (Object)this.j);
      }
   }

   private void g(zpb var1) throws Exception {
      this.a(var1);

      while(true) {
         this.g = var1.b(this.i);
         switch(this.g) {
         case 10:
            var1.a(2);
            int var2 = ((this.b.I() * 8 + this.b.J()) / 8 + 1) * 8;
            double var3 = (double)(var2 - this.b.J()) / (double)this.b.I();

            for(int var10 = 0; var10 < this.b.getCount(); ++var10) {
               Cells var11 = this.b.get(var10).getCells();
               var11.a(var3);
            }

            zhu.c();
            return;
         case 23:
            this.h(var1);
            break;
         case 24:
            this.o(var1);
            break;
         case 47:
            this.h = var1.b(this.i);
            this.j = new byte[this.h];
            var1.a(this.j);
            if (this.j[0] == 0 && this.j[1] == 0) {
               throw new CellsException(19, "BIFF7 Encryption is not supported.");
            }

            if (this.j[4] != 1) {
               throw new CellsException(19, "Strong Workbook Encryption is not supported.");
            }

            byte[] var5 = new byte[16];
            byte[] var6 = new byte[16];
            byte[] var7 = new byte[16];
            System.arraycopy(this.j, 6, var5, 0, 16);
            System.arraycopy(this.j, 22, var6, 0, 16);
            System.arraycopy(this.j, 38, var7, 0, 16);

            try {
               if (this.a.getSettings().getPassword() != null && !"".equals(this.a.getSettings().getPassword())) {
                  this.o = new zsg(this.a.getSettings().getPassword(), var5, var6, var7);
                  break;
               }

               this.o = new zsg("VelvetSweatshop", var5, var6, var7);
               break;
            } catch (Exception var9) {
               if (this.a.getSettings().getPassword() != null && !"".equals(this.a.getSettings().getPassword())) {
                  throw new CellsException(8, "Invalid password.");
               }

               throw new CellsException(8, "Please provide password for the Workbook file.");
            }
         case 49:
            this.m(var1);
            break;
         case 61:
            this.n(var1);
            break;
         case 133:
            this.k(var1);
            break;
         case 146:
            this.H(var1);
            break;
         case 224:
            this.d(var1);
            break;
         case 252:
            this.f(var1);
            break;
         case 430:
            this.i(var1);
            break;
         case 659:
            this.j(var1);
            break;
         case 1054:
            this.b(var1);
            break;
         default:
            this.h = var1.b(this.i);
            var1.a(this.h & '\uffff');
         }
      }
   }

   private void h(zpb var1) throws Exception {
      this.c(var1);
      int var2 = com.aspose.cells.b.a.zc.e(this.j, 0);
      this.b.q().clear();
      int var3;
      int var4;
      int var5;
      int var6;
      if ((var2 & '\uffff') * 6 + 2 > 8224) {
         var3 = (this.j.length - 2) / 6;

         int var7;
         for(var4 = 0; var4 < var3; ++var4) {
            var5 = com.aspose.cells.b.a.zc.e(this.j, 6 * var4 + 2);
            var6 = com.aspose.cells.b.a.zc.e(this.j, 6 * var4 + 4);
            var7 = com.aspose.cells.b.a.zc.e(this.j, 6 * var4 + 6);
            this.b.q().b(var5, var6, var7);
         }

         while(true) {
            this.g = var1.b(this.i);
            if ((this.g & '\uffff') != 60) {
               var1.a(-2);
               break;
            }

            this.c(var1);
            var3 = this.j.length / 6;

            for(var4 = 0; var4 < var3; ++var4) {
               var5 = com.aspose.cells.b.a.zc.e(this.j, 6 * var4);
               var6 = com.aspose.cells.b.a.zc.e(this.j, 6 * var4 + 2);
               var7 = com.aspose.cells.b.a.zc.e(this.j, 6 * var4 + 4);
               this.b.q().b(var5, var6, var7);
            }
         }
      } else {
         for(var3 = 0; var3 < (var2 & '\uffff'); ++var3) {
            var4 = com.aspose.cells.b.a.zc.e(this.j, 6 * var3 + 2);
            var5 = com.aspose.cells.b.a.zc.e(this.j, 6 * var3 + 4);
            var6 = com.aspose.cells.b.a.zc.e(this.j, 6 * var3 + 6);
            this.b.q().b(var4, var5, var6);
         }
      }

   }

   private void i(zpb var1) throws Exception {
      this.c(var1);
      if (this.b.v() == null) {
         this.b.a(new zbqf());
      }

      zbqg var2 = new zbqg();
      byte var4;
      int var9;
      if (this.j.length == 4) {
         if (this.j[2] == 1 && this.j[3] == 4) {
            var2.a(1);
            this.b.d(this.b.v().getCount());
         } else if (this.j[0] == 1 && this.j[2] == 1 && this.j[3] == 58) {
            var2.a(2);
         }
      } else {
         int var3 = com.aspose.cells.b.a.zc.e(this.j, 0) & '\uffff';
         var2.a(var3 == 0 ? 3 : 0);
         var4 = 2;
         int var5 = com.aspose.cells.b.a.zc.e(this.j, var4) & '\uffff';
         if (this.j[var4 + 2] == 1) {
            var2.d(Encoding.getUnicode().a(this.j, var4 + 3, var5 * 2));
            var9 = var4 + 3 + var5 * 2;
         } else {
            var2.d(Encoding.getASCII().a(this.j, var4 + 3, var5));
            var9 = var4 + 3 + var5;
         }

         if (var3 != 0) {
            String[] var6 = new String[var3];

            for(int var7 = 0; var7 < var3; ++var7) {
               var5 = com.aspose.cells.b.a.zc.e(this.j, var9) & '\uffff';
               if (this.j[var9 + 2] == 1) {
                  var6[var7] = Encoding.getUnicode().a(this.j, var9 + 3, var5 * 2);
                  var9 += 3 + var5 * 2;
               } else {
                  var6[var7] = Encoding.getASCII().a(this.j, var9 + 3, var5);
                  var9 += 3 + var5;
               }

               if (var9 >= (this.h & '\uffff') && var7 != var3 - 1) {
                  this.g = var1.b(this.i);
                  if ((this.g & '\uffff') != 60) {
                     var1.a(-2);
                     break;
                  }

                  this.c(var1);
                  var9 = 0;
               }
            }

            var2.a(var6);
         }
      }

      while(true) {
         this.g = var1.b(this.i);
         if ((this.g & '\uffff') != 35) {
            var1.a(-2);
            this.b.v().a(var2);

            while(true) {
               this.g = var1.b(this.i);
               if ((this.g & '\uffff') != 89) {
                  var1.a(-2);
                  return;
               }

               this.a(var1, var2);
            }
         }

         this.c(var1);
         zuk var8 = new zuk(var2);
         var8.d(com.aspose.cells.b.a.zc.e(this.j, 0));
         var8.a(com.aspose.cells.b.a.zc.a(this.j, 2));
         var4 = 8;
         if (this.j[7] == 0) {
            var8.a(Encoding.getASCII().a(this.j, 8, this.j[6] & 255));
            var9 = var4 + (this.j[6] & 255);
         } else {
            var8.a(Encoding.getUnicode().a(this.j, 8, (this.j[6] & 255) * 2));
            var9 = var4 + (this.j[6] & 255) * 2;
         }

         if (this.j.length - var9 > 0) {
            byte[] var10 = new byte[this.j.length - var9];
            System.arraycopy(this.j, var9, var10, 0, var10.length);
            var8.b(var10);
         }

         if (var2.a() == 3 && var2.b().size() == 0 && this.j.length == 9) {
            var2.a(4);
         }

         com.aspose.cells.b.a.a.ze.a(var2.b(), (Object)var8);
      }
   }

   private void a(zpb var1, zbqg var2) throws Exception {
      this.c(var1);
      int var3 = com.aspose.cells.b.a.zc.e(this.j, 0) & '\uffff';
      int var4 = com.aspose.cells.b.a.zc.e(this.j, 2) & '\uffff';
      if (var3 != 0) {
         zut var5 = var2.b(var4);

         for(int var6 = 0; var6 < var3; ++var6) {
            this.g = var1.b(this.i);
            if ((this.g & '\uffff') != 90 && (this.g & '\uffff') != 60) {
               var1.a(-2);
               return;
            }

            this.c(var1);
            int var7 = this.j[1] & 255;
            int var8 = this.j[0] & 255;
            int var9 = com.aspose.cells.b.a.zc.e(this.j, 2) & '\uffff';
            zuq var10 = var5.e(var9);
            int var11 = 4;

            for(int var12 = var7; var12 <= var8; ++var12) {
               if (var11 >= this.j.length) {
                  this.g = var1.b(this.i);
                  if ((this.g & '\uffff') != 60) {
                     var1.a(-2);
                     break;
                  }

                  this.c(var1);
                  var11 = 0;
               }

               if (this.j[var11] != 2 && var11 + 9 > this.j.length) {
                  byte[] var13 = this.j;
                  this.g = var1.b(this.i);
                  if ((this.g & '\uffff') != 60) {
                     var1.a(-2);
                     break;
                  }

                  this.c(var1);
                  byte[] var14 = this.j;
                  this.j = new byte[this.j.length + var13.length - var11];
                  System.arraycopy(var13, var11, this.j, 0, var13.length - var11);
                  System.arraycopy(var14, var13.length - var11, this.j, 0, var14.length);
                  var11 = 0;
               }

               switch(this.j[var11]) {
               case 0:
                  var11 += 9;
                  break;
               case 1:
                  var10.a(var12, (Object)com.aspose.cells.b.a.zc.f(this.j, var11 + 1));
                  var11 += 9;
                  break;
               case 2:
                  int var15 = com.aspose.cells.b.a.zc.e(this.j, var11 + 1) & '\uffff';
                  if (this.j[var11 + 3] == 0) {
                     var10.a(var12, (Object)Encoding.getASCII().a(this.j, var11 + 4, var15));
                     var11 += 4 + var15;
                  } else {
                     var10.a(var12, (Object)Encoding.getUnicode().a(this.j, var11 + 4, var15 * 2));
                     var11 += 4 + var15 * 2;
                  }
                  break;
               case 4:
                  var10.a(var12, (Object)(this.j[var11 + 1] == 1));
                  var11 += 9;
                  break;
               case 16:
                  var10.a(var12, (Object)zsk.a(this.j[var11 + 1]));
                  var11 += 9;
                  break;
               default:
                  return;
               }
            }
         }

      }
   }

   private void j(zpb var1) throws Exception {
      this.c(var1);
      if (this.m == null) {
         this.m = new ArrayList();
      }

      com.aspose.cells.b.a.a.ze.a(this.m, (Object)this.j);

      while(true) {
         this.g = var1.b(this.i);
         if ((this.g & '\uffff') != 659) {
            var1.a(-2);
            return;
         }

         this.c(var1);
         com.aspose.cells.b.a.a.ze.a(this.m, (Object)this.j);
      }
   }

   private void k(zpb var1) throws Exception {
      int var2;
      byte[] var3;
      for(var2 = 0; var2 < this.n.size(); ++var2) {
         var3 = (byte[])((byte[])this.n.get(var2));
         this.c(var3);
      }

      this.n = null;

      for(var2 = 0; var2 < this.l.size(); ++var2) {
         var3 = (byte[])((byte[])this.l.get(var2));
         this.a(var3);
      }

      if (this.m != null) {
         for(var2 = 0; var2 < this.m.size(); ++var2) {
            var3 = (byte[])((byte[])this.m.get(var2));
            this.b(var3);
         }
      }

      this.b.K();
      this.l = null;
      this.h = var1.b(this.i);
      this.j = new byte[this.h];
      var1.a(this.j);
      byte[] var4;
      long var5;
      if (this.o != null) {
         var5 = var1.b() - (long)this.j.length + 4L;
         var4 = this.o.a(this.j, 4, this.j.length - 4, var5);
         System.arraycopy(var4, 0, this.j, 4, var4.length);
      }

      this.e(var1);

      while(true) {
         this.g = var1.b(this.i);
         if ((this.g & '\uffff') != 133) {
            var1.a(-2);
            return;
         }

         this.h = var1.b(this.i);
         this.j = new byte[this.h];
         var1.a(this.j);
         if (this.o != null) {
            var5 = var1.b() - (long)this.j.length + 4L;
            var4 = this.o.a(this.j, 4, this.j.length - 4, var5);
            System.arraycopy(var4, 0, this.j, 4, var4.length);
         }

         this.e(var1);
      }
   }

   private void b(byte[] var1) throws Exception {
      int var2 = com.aspose.cells.b.a.zc.e(var1, 0) & '\uffff';
      int var3 = var2 & '耀';
      var2 &= 4095;
      String var4 = "";
      if (var3 == 0) {
         if (var1[2] == 0) {
            return;
         }

         if (var1[4] == 0) {
            byte[] var5 = new byte[2 * var1.length - 10];

            for(int var6 = 0; var6 < var1.length - 5; ++var6) {
               var5[2 * var6] = var1[var6 + 5];
            }

            var4 = Encoding.getUnicode().a(var5);
         } else {
            var4 = Encoding.getUnicode().a(var1, 5, var1.length - 5);
         }
      } else {
         switch(var1[2]) {
         case 0:
            var4 = "Normal";
            break;
         case 1:
            var4 = "RowLevel_" + Byte.toString(var1[3]);
            break;
         case 2:
            var4 = "ColLevel_" + Byte.toString(var1[3]);
            break;
         case 3:
            var4 = "Comma";
            break;
         case 4:
            var4 = "Currency";
            break;
         case 5:
            var4 = "Percent";
            break;
         case 6:
            var4 = "Comma [0]";
            break;
         case 7:
            var4 = "Currency [0]";
            break;
         case 8:
            var4 = "Hyperlink";
            break;
         case 9:
            var4 = "Followed Hyperlink";
         }
      }

      if (var4 != null && !"".equals(var4)) {
         Style var7 = this.b.B().a(var2);
         this.b.r().a(var7);
         var7.a(var4);
      }

   }

   private void l(zpb var1) throws Exception {
      if (this.o != null) {
         long var2 = var1.b() - (long)this.j.length;
         this.j = this.o.a(this.j, 0, this.j.length, var2);
      }

   }

   private void m(zpb var1) throws Exception {
      this.n = new ArrayList();
      this.c(var1);
      com.aspose.cells.b.a.a.ze.a(this.n, (Object)this.j);

      while(true) {
         this.g = var1.b(this.i);
         if ((this.g & '\uffff') != 49) {
            var1.a(-2);
            return;
         }

         this.c(var1);
         com.aspose.cells.b.a.a.ze.a(this.n, (Object)this.j);
      }
   }

   private void c(byte[] var1) {
      Font var2 = new Font(this.b, (Object)null, false);
      var2.a(var1);
      if (this.b.z().size() > 3) {
         var2.d(this.b.z().size() + 1);
      } else {
         var2.d(this.b.z().size());
      }

      com.aspose.cells.b.a.a.ze.a(this.b.z(), (Object)var2);
   }

   private void n(zpb var1) throws Exception {
      this.c(var1);
      byte var2 = this.j[8];
      byte var3 = (byte)(var2 & 255 & 8);
      if (var3 == 0) {
         this.b.n().getSettings().setHScrollBarVisible(false);
      } else {
         this.b.n().getSettings().setHScrollBarVisible(true);
      }

      var3 = (byte)(var2 & 255 & 16);
      if (var3 == 0) {
         this.b.n().getSettings().setVScrollBarVisible(false);
      } else {
         this.b.n().getSettings().setVScrollBarVisible(true);
      }

      var3 = (byte)(var2 & 255 & 32);
      if (var3 == 0) {
         this.b.n().getSettings().setShowTabs(false);
      } else {
         this.b.n().getSettings().setShowTabs(true);
      }

      this.b.c(com.aspose.cells.b.a.zc.e(this.j, 10) & '\uffff');
      this.b.l(com.aspose.cells.b.a.zc.e(this.j, 12));
   }

   private void o(zpb var1) throws Exception {
      this.c(var1);
      this.a();

      while(true) {
         this.g = var1.b(this.i);
         if ((this.g & '\uffff') != 24) {
            var1.a(-2);
            return;
         }

         this.c(var1);
         this.a();
      }
   }

   private void a() {
      Name var1 = new Name(this.b);
      var1.b(this.j);
      this.b.getNames().a(var1, false);
   }

   private void p(zpb var1) throws Exception {
      this.c(var1);
      this.j[14] = (byte)(this.j[14] | 2);
      int var2 = com.aspose.cells.b.a.zc.e(this.j, 0);
      int var3 = com.aspose.cells.b.a.zc.e(this.j, 2);
      int var4 = com.aspose.cells.b.a.zc.e(this.j, 4);
      Cell var5 = this.c.getRows().a(var2 & '\uffff', var3 & '\uffff', false, false, false);
      var5.b(var4);
      double var6;
      if ((this.j[12] & 255) == 255 && (this.j[13] & 255) == 255) {
         switch(this.j[6]) {
         case 0:
         case 3:
            break;
         case 1:
            var5.a(2, this.j[8] == 0 ? zml.e : zml.d);
            break;
         case 2:
            var5.a(2, this.j[8]);
            break;
         default:
            var6 = com.aspose.cells.b.a.zc.f(this.j, 6);
            if (var6 == 0.0D) {
               var5.a(1, zml.g);
            } else {
               var5.a(1, var6);
            }
         }
      } else {
         var6 = com.aspose.cells.b.a.zc.f(this.j, 6);
         if (var6 == 0.0D) {
            var5.a(1, zml.g);
         } else {
            var5.a(1, var6);
         }
      }

      this.g = var1.b(this.i);
      String var9;
      switch(this.g) {
      case 519:
         this.c(var1);
         if (this.j[2] != 0) {
            var9 = Encoding.getUnicode().a(this.j, 3, this.j.length - 3);
         } else {
            byte[] var7 = new byte[2 * this.j.length - 6];

            for(int var8 = 0; var8 < this.j.length - 3; ++var8) {
               var7[2 * var8] = this.j[var8 + 3];
            }

            var9 = Encoding.getUnicode().a(var7);
         }

         var5.putValue(var9);
         break;
      case 545:
      case 1212:
         this.h = var1.b(this.i);
         var1.a(this.h & '\uffff');
         this.g = var1.b(this.i);
         if ((this.g & '\uffff') == 519) {
            this.c(var1);
            if (this.j[2] == 0) {
               var9 = Encoding.getASCII().a(this.j, 3, this.j.length - 3);
            } else {
               var9 = Encoding.getUnicode().a(this.j, 3, this.j.length - 3);
            }

            var5.putValue(var9);
         } else {
            var1.a(-2);
         }
         break;
      default:
         var1.a(-2);
      }

   }

   private void q(zpb var1) throws Exception {
      int var2;
      int var3;
      Cell var5;
      int var9;
      this.c(var1);
      var2 = com.aspose.cells.b.a.zc.e(this.j, 0);
      var3 = com.aspose.cells.b.a.zc.e(this.j, 2);
      int var4 = com.aspose.cells.b.a.zc.e(this.j, 4);
      var5 = this.c.getRows().a(var2 & '\uffff', var3 & '\uffff', false, false, false);
      var5.b(var4);
      zyi var6 = this.a(var2 & '\uffff', var3 & '\uffff');
      var5.a(var6);
      this.g = var1.b(this.i);
      String var7;
      label53:
      switch(this.g) {
      case 519:
         this.c(var1);
         if (this.j[2] != 0) {
            var7 = Encoding.getUnicode().a(this.j, 3, this.j.length - 3);
         } else {
            byte[] var8 = new byte[2 * this.j.length - 6];

            for(var9 = 0; var9 < this.j.length - 3; ++var9) {
               var8[2 * var9] = this.j[var9 + 3];
            }

            var7 = Encoding.getUnicode().a(var8);
         }

         var5.a(4, var7);
         break;
      case 545:
         this.a(var5, var1);
         this.g = var1.b(this.i);
         if ((this.g & '\uffff') == 519) {
            this.c(var1);
            if (this.j[2] == 0) {
               var7 = Encoding.getASCII().a(this.j, 3, this.j.length - 3);
            } else {
               var7 = Encoding.getUnicode().a(this.j, 3, this.j.length - 3);
            }

            var5.a(4, var7);
         } else {
            var1.a(-2);
         }
         break;
      case 1212:
         this.b(var5, var1);
         this.g = var1.b(this.i);
         switch(this.g) {
         case 519:
            this.c(var1);
            if (this.j[2] == 0) {
               var7 = zco.a(this.j, 3, this.j.length - 3);
            } else {
               var7 = Encoding.getUnicode().a(this.j, 3, this.j.length - 3);
            }

            var5.a(4, var7);
            break label53;
         case 545:
            this.a(var5, var1);
            break label53;
         default:
            var1.a(-2);
            break label53;
         }
      default:
         var1.a(-2);
      }

      if (var5.isArrayHeader()) {
         CellArea var13 = var5.D().a();
         var9 = var13.EndRow;
         int var10 = var13.EndColumn;
         if (var13.StartRow < var9 || var13.StartColumn < var10) {
            int var11 = var2 & '\uffff';
            int var12 = var3 & '\uffff';
            this.e.put(var11 << 8 | var12, var9 << 8 | var10);
         }
      }

   }

   zyi a(int var1, int var2) {
      byte[] var3 = new byte[this.j.length - 20];
      System.arraycopy(this.j, 20, var3, 0, var3.length);
      byte var4 = 0;
      Object var5 = null;
      if ((this.j[12] & 255) == 255 && (this.j[13] & 255) == 255) {
         switch(this.j[6]) {
         case 0:
         case 3:
            break;
         case 1:
            var4 = 2;
            var5 = this.j[8] == 0 ? zml.e : zml.d;
            break;
         case 2:
            var4 = 3;
            var5 = com.aspose.cells.a.c.zi.a(this.j[8]);
            break;
         default:
            var4 = 1;
            var5 = com.aspose.cells.b.a.zc.f(this.j, 6);
         }
      } else {
         var4 = 1;
         var5 = com.aspose.cells.b.a.zc.f(this.j, 6);
      }

      zyi var6 = new zyi(var1, var2);
      var6.b = var3;
      var6.c = var4;
      var6.d = var5;
      if (var3[0] == 5 && var3[1] == 0 && var3[2] == 1) {
         byte var7 = 0;
         byte var8 = 0;
         int[] var9 = new int[]{var7};
         int[] var10 = new int[]{var8};
         this.c.r().x().a(var3, var9, var10);
         int var14 = var9[0];
         int var15 = var10[0];
         if (var14 != var1 || var15 != var2) {
            Integer var11 = var14 << 8 | var15;
            Object var12 = this.e.get(var11);
            if (var12 != null) {
               var6.b(true);
               int var13 = (Integer)var12;
               if (var1 == var13 >> 8 && var2 == (var13 & 255)) {
                  this.e.put(var11, (Object)null);
               }
            }
         }
      }

      return var6;
   }

   private void a(Cell var1, zpb var2) throws Exception {
      this.c(var2);
      CellArea var3 = new CellArea();
      var3.StartRow = com.aspose.cells.b.a.zc.e(this.j, 0) & '\uffff';
      var3.EndRow = com.aspose.cells.b.a.zc.e(this.j, 2) & '\uffff';
      var3.StartColumn = this.j[4] & 255;
      var3.EndColumn = this.j[5] & 255;
      byte[] var4 = new byte[(this.h & '\uffff') - 12];
      System.arraycopy(this.j, 12, var4, 0, var4.length);
      var1.a(new zaz(var3, true, var4));
      var1.g().b(true);
   }

   private void b(Cell var1, zpb var2) throws Exception {
      this.c(var2);
      CellArea var3 = new CellArea();
      var3.StartRow = com.aspose.cells.b.a.zc.e(this.j, 0) & '\uffff';
      var3.EndRow = com.aspose.cells.b.a.zc.e(this.j, 2) & '\uffff';
      var3.StartColumn = this.j[4] & 255;
      var3.EndColumn = this.j[5] & 255;
      byte[] var4 = new byte[(this.h & '\uffff') - 8];
      System.arraycopy(this.j, 8, var4, 0, var4.length);
      var1.a(new zaz(var3, false, var4));
   }

   private void r(zpb var1) throws Exception {
      this.c(var1);
      int var2 = com.aspose.cells.b.a.zc.e(this.j, 0);
      byte var3 = this.j[2];
      int var4 = com.aspose.cells.b.a.zc.e(this.j, 4);
      byte var5 = this.j[6];
      byte var6 = this.j[7];
      Cell var7;
      if (var6 == 0) {
         var7 = this.c.getRows().a(var2 & '\uffff', var3 & 255, false, false, false);
         var7.b(var4);
         boolean var8;
         if (var5 == 0) {
            var8 = false;
         } else {
            var8 = true;
         }

         var7.putValue(var8);
      } else {
         var7 = this.c.getRows().a(var2 & '\uffff', var3 & 255, false, false, false);
         var7.b(var4);
         var7.a(3, var5);
      }

   }

   private void s(zpb var1) throws Exception {
      this.c(var1);
      int var2 = com.aspose.cells.b.a.zc.e(this.j, 0);
      byte var3 = this.j[2];
      int var4 = com.aspose.cells.b.a.zc.e(this.j, 4);
      Cell var5 = this.c.getRows().a(var2 & '\uffff', var3 & 255, false, false, false);
      var5.b(var4);
   }

   private void t(zpb var1) throws Exception {
      this.c(var1);
      int var2 = com.aspose.cells.b.a.zc.e(this.j, 0);
      byte var3 = this.j[2];

      for(int var4 = 0; var4 < this.j.length / 2 - 3; ++var4) {
         int var5 = com.aspose.cells.b.a.zc.e(this.j, 4 + 2 * var4);
         Cell var6 = this.c.getRows().a(var2 & '\uffff', (var3 & 255) + var4, false, false, false);
         var6.b(var5);
      }

   }

   private void u(zpb var1) throws Exception {
      this.c(var1);
      int var2 = com.aspose.cells.b.a.zc.e(this.j, 0);
      byte var3 = this.j[2];
      int var4 = com.aspose.cells.b.a.zc.e(this.j, 4);
      double var5 = com.aspose.cells.b.a.zc.f(this.j, 6);
      Cell var7 = this.c.getRows().a(var2 & '\uffff', var3 & 255, false, false, false);
      var7.b(var4);
      var7.putValue(var5);
   }

   private void v(zpb var1) throws Exception {
      this.c(var1);
      int var2 = com.aspose.cells.b.a.zc.e(this.j, 0);
      byte var3 = this.j[2];
      int var4 = com.aspose.cells.b.a.zc.e(this.j, 4);
      int var5 = com.aspose.cells.b.a.zc.a(this.j, 6);
      double var6 = 0.0D;
      if ((var5 & 2) != 0) {
         var6 = (double)(var5 >> 2);
      } else {
         int var8 = var5 - (var5 & 3);
         byte[] var9 = new byte[8];
         System.arraycopy(com.aspose.cells.b.a.zc.a(var8), 0, var9, 4, 4);
         var6 = com.aspose.cells.b.a.zc.f(var9, 0);
      }

      if ((var5 & 1) != 0) {
         var6 /= 100.0D;
      }

      Cell var10 = this.c.getRows().a(var2 & '\uffff', var3 & 255, false, false, false);
      var10.b(var4);
      var10.putValue(var6);
   }

   private void w(zpb var1) throws Exception {
      this.c(var1);
      int var2 = com.aspose.cells.b.a.zc.e(this.j, 0);
      int var3 = com.aspose.cells.b.a.zc.e(this.j, 2);
      int var4 = ((this.h & '\uffff') - 6) / 6;

      for(int var5 = 0; var5 < var4; ++var5) {
         int var6 = com.aspose.cells.b.a.zc.e(this.j, 4 + 6 * var5);
         int var7 = com.aspose.cells.b.a.zc.a(this.j, 6 + 6 * var5);
         double var8 = 0.0D;
         if ((var7 & 2) != 0) {
            var8 = (double)(var7 >> 2);
         } else {
            int var10 = var7 - (var7 & 3);
            byte[] var11 = new byte[8];
            System.arraycopy(com.aspose.cells.b.a.zc.a(var10), 0, var11, 4, 4);
            var8 = com.aspose.cells.b.a.zc.f(var11, 0);
         }

         if ((var7 & 1) != 0) {
            var8 /= 100.0D;
         }

         Cell var12 = this.c.getRows().a(var2 & '\uffff', (var3 & '\uffff') + var5, false, false, false);
         var12.b(var6);
         var12.a(1, var8, false);
      }

   }

   private void x(zpb var1) throws Exception {
      this.c(var1);
      int var2 = com.aspose.cells.b.a.zc.e(this.j, 0);
      byte var3 = this.j[2];
      int var4 = com.aspose.cells.b.a.zc.e(this.j, 4);
      int var5 = com.aspose.cells.b.a.zc.a(this.j, 6);
      Cell var6 = this.c.getRows().a(var2 & '\uffff', var3 & 255, false, false, false);
      var6.b(var4);
      var6.a(4, this.c.e().a(var5), false);
   }

   private void y(zpb var1) throws Exception {
      this.h = var1.b(this.i);
      var1.a(this.h & '\uffff');
      this.g = var1.b(this.i);
      if ((this.g & '\uffff') != 93) {
         var1.a(-2);
      } else {
         this.c(var1);
         if (this.j[4] == 5) {
            this.g = var1.b(this.i);
            if ((this.g & '\uffff') != 2057) {
               this.h = var1.b(this.i);
               var1.a(this.h & '\uffff');
            } else {
               var1.a(18);

               while(true) {
                  this.g = var1.b(this.i);
                  switch(this.g) {
                  case 10:
                     var1.a(2);
                     return;
                  default:
                     this.h = var1.b(this.i);
                     var1.a(this.h & '\uffff');
                  }
               }
            }
         }
      }
   }

   private void z(zpb var1) throws Exception {
      int var2 = 0;

      while(true) {
         while(true) {
            this.g = var1.b(this.i);
            switch(this.g) {
            case 10:
               var1.a(2);
               --var2;
               if (var2 == 0) {
                  return;
               }
               break;
            case 2057:
               this.h = var1.b(this.i);
               var1.a(this.h & '\uffff');
               ++var2;
               break;
            default:
               this.h = var1.b(this.i);
               var1.a(this.h & '\uffff');
            }
         }
      }
   }

   private void A(zpb var1) throws Exception {
      while(true) {
         this.g = var1.b(this.i);
         switch(this.g) {
         case 6:
         case 1030:
            if (this.k != null && !this.k.getImportFormula()) {
               this.p(var1);
               break;
            }

            this.q(var1);
            break;
         case 10:
            var1.a(2);
            return;
         case 85:
            this.D(var1);
            break;
         case 125:
            this.E(var1);
            break;
         case 189:
            this.w(var1);
            break;
         case 190:
            this.t(var1);
            break;
         case 236:
            this.y(var1);
            break;
         case 253:
            this.x(var1);
            break;
         case 513:
            this.s(var1);
            break;
         case 515:
            this.u(var1);
            break;
         case 517:
            this.r(var1);
            break;
         case 520:
            this.B(var1);
            break;
         case 549:
            this.C(var1);
            break;
         case 574:
            this.F(var1);
            break;
         case 638:
            this.v(var1);
            break;
         default:
            this.h = var1.b(this.i);
            var1.a(this.h & '\uffff');
         }
      }
   }

   private void B(zpb var1) throws Exception {
      this.c(var1);
      zbbj var2 = new zbbj();
      var2.a = com.aspose.cells.b.a.zc.e(this.j, 0) & '\uffff';
      short var3 = com.aspose.cells.b.a.zc.b(this.j, 2);
      short var4 = com.aspose.cells.b.a.zc.b(this.j, 4);
      if ((this.j[7] & 255 & 128) == 0) {
         var2.e = (short)Math.min(com.aspose.cells.b.a.zc.b(this.j, 6), 8190);
      } else {
         var2.e = (short)Math.min(com.aspose.cells.b.a.zc.b(this.j, 6) & 32767, 8190);
      }

      Row var5 = this.c.getRows().a(var2.a, false, false, false);
      var2.b = this.j[12];
      var2.c = this.j[15];
      var2.d = this.j[14] & 255 | (var2.c & 255 & 15) << 8;
      if (var2.d < 15) {
         var2.d = 15;
      }

      var2.c = (byte)(var2.c & 240);
      var5.a.b(var2, 13);
      if ((var2.e() & 255) > (this.c.v() & 255)) {
         this.c.c(var2.e());
      }

   }

   private void C(zpb var1) throws Exception {
      this.c(var1);
      byte var2 = this.j[0];
      int var3 = com.aspose.cells.b.a.zc.e(this.j, 2);
      int var4 = var1.b(this.i);
      if ((var4 & '\uffff') != 128) {
         this.c.a(var2);
         this.c.a = (double)(var3 & '\uffff');
      }

      var1.a(-2);
   }

   private void D(zpb var1) throws Exception {
      this.c(var1);
      int var2 = com.aspose.cells.b.a.zc.e(this.j, 0);
      if ((var2 & '\uffff') != 8) {
         int var3 = (var2 & '\uffff') * 8;
         double var4 = 0.0D;
         if (var3 >= 12) {
            var4 = (double)(var3 - 5) / 7.0D;
         } else {
            var4 = (double)var3 / 12.0D;
         }

         this.c.a(var4);
      }

      this.g = var1.b(this.i);
      if ((this.g & '\uffff') == 512) {
         this.c(var1);
      } else {
         var1.a(-2);
      }

   }

   private void E(zpb var1) throws Exception {
      this.c(var1);
      int var2 = com.aspose.cells.b.a.zc.e(this.j, 0);
      int var3 = com.aspose.cells.b.a.zc.e(this.j, 2);

      for(int var4 = var2 & '\uffff'; var4 <= (var3 & '\uffff') && var4 <= 255; ++var4) {
         Column var5 = this.c.getColumns().get(var4);
         var5.a(this.j);
         if ((var5.b() & 255) > (this.c.u() & 255)) {
            this.c.b(var5.b());
         }
      }

   }

   private void F(zpb var1) throws Exception {
      this.c(var1);
      this.d.b(com.aspose.cells.b.a.zc.e(this.j, 0) & '\uffff' & 1023);
      if ((this.j[1] & 255 & 8) != 0) {
         this.d.setViewType(1);
      }

      this.d.setFirstVisibleRow(com.aspose.cells.b.a.zc.e(this.j, 2));
      this.d.setFirstVisibleColumn(this.j[4] & 255 & 255);
      this.d.f(this.j[6]);
      if ((this.h & '\uffff') > 10) {
         int var2 = com.aspose.cells.b.a.zc.e(this.j, 10) & '\uffff';
         if (var2 != 0) {
            this.d.u()[1] = var2;
         }

         var2 = com.aspose.cells.b.a.zc.e(this.j, 12) & '\uffff';
         if (var2 != 0) {
            this.d.u()[0] = var2;
         }
      }

   }

   private void G(zpb var1) throws Exception {
      for(int var2 = 0; var2 < this.b.getCount(); ++var2) {
         if (this.k != null) {
            boolean var3 = false;
            int var4;
            if (this.k.SheetNames != null) {
               for(var4 = 0; var4 < this.k.SheetNames.length; ++var4) {
                  if (com.aspose.cells.b.a.zv.b(this.b.get(var2).getName().toUpperCase(), this.k.SheetNames[var4].toUpperCase())) {
                     var3 = true;
                     break;
                  }
               }
            } else if (this.k.SheetIndexes != null) {
               for(var4 = 0; var4 < this.k.SheetIndexes.length; ++var4) {
                  if (var2 == this.k.SheetIndexes[var4]) {
                     var3 = true;
                     break;
                  }
               }
            } else {
               var3 = true;
            }

            if (!var3) {
               this.z(var1);
               continue;
            }
         }

         this.d = this.b.get(var2);
         this.c = this.d.getCells();
         if (this.d.getType() != 2) {
            this.A(var1);
         } else {
            this.d.setType(1);

            for(this.g = var1.b(this.i); (this.g & '\uffff') != 10; this.g = var1.b(this.i)) {
               this.h = var1.b(this.i);
               var1.a(this.h & '\uffff');
            }

            var1.a(2);
         }
      }

   }

   void a(zvh var1) throws Exception {
      com.aspose.cells.b.a.d.zh var2 = var1.a().a("Workbook");
      if (var2 == null) {
         var2 = var1.a().a("WORKBOOK");
      }

      if (var2 == null) {
         throw new CellsException(4, "Invalid BIFF8 file.");
      } else {
         this.a(var2);
      }
   }

   private void a(com.aspose.cells.b.a.d.zh var1) throws Exception {
      zpb var2 = new zpb(var1);
      this.b.t();
      this.g(var2);
      if (!this.k.getOnlyCreateWorksheet()) {
         int var3 = 0;
         int var6;
         if (this.b.v() != null && this.b.v().getCount() != 0) {
            for(var6 = 0; var6 < this.b.v().getCount(); ++var6) {
               zbqg var5 = this.b.v().a(var6);
               if (var5.e()) {
                  var3 = var6;
                  break;
               }
            }
         } else {
            this.b.a(new zbqf());
            zbqg var4 = new zbqg();
            var4.a(1);
            this.b.v().a(var4);
            var3 = 0;
         }

         for(var6 = 0; var6 < this.b.getCount(); ++var6) {
            this.b.q().a(var3, var6, var6);
         }

         this.b.getExternalLinks().a(this.b.v());
         this.G(var2);
         this.b.g.e();
      }
   }

   private void H(zpb var1) throws Exception {
      this.c(var1);
      int var2 = com.aspose.cells.b.a.zc.e(this.j, 0);

      for(int var3 = 0; var3 < (var2 & '\uffff'); ++var3) {
         int var4 = com.aspose.cells.b.a.zc.a(this.j, 4 * var3 + 2);
         this.b.m().a(var4, var3 + 8);
      }

   }
}
